import DefaultPlatform from "./DefaultPlatform";
import Platform = require('./Platform');
import WebAndroidPlatform from './WebAndroidPlatform';
import WebIOSPlatform from './WebIOSPlatform';

export default class PlatformUtil {

    public static platform: Platform;

    public static init() {

        console.log("平台",cc.sys.os)
        switch (cc.sys.platform) {
            case cc.sys.WECHAT_GAME:
                console.log("微信小游戏平台")
                break;
            case cc.sys.ANDROID:
                console.log("安卓app平台")
                break;
            case cc.sys.IPHONE:
            case cc.sys.IPAD:
                console.log("IOSapp平台")
                break;
            default:
                if (cc.sys.isBrowser) {
                    switch (cc.sys.os) {
                        case cc.sys.OS_ANDROID:
                            this.platform = new WebAndroidPlatform();
                            break;
                        case cc.sys.OS_IOS:
                        console.log("IOS网页版")
                            this.platform = new WebIOSPlatform();
                            break;
                        default:
                            this.platform = new DefaultPlatform();
                            console.log("Pc或者其他网页版")
                            break;
                    }

                } else {
                    this.platform = new DefaultPlatform();
                }
                break;

        }
        window['platform'] = this.platform;

    }

}